import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class IOTest02 {
    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream = null;
        //改进Test01
        try {
             fileInputStream = new FileInputStream("C:\\Users\\30539\\Desktop\\text.txt");

             //读取数据 但是这种读取方式：内存和硬盘之间的交互太频繁了。导致效率低下。
            int readData = 0;
             while((readData = fileInputStream.read())!= -1){
                 System.out.println(readData);
             }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            if(fileInputStream!=null){
                try {
                    fileInputStream.close();
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
